﻿using System.IO;

namespace LS.Screening.UI.Common
{
    public static class FolderHelper
    {
        /// <summary>
        /// 筛查模块：基目录名称
        /// </summary>
        static readonly string BasePath_Screening = "Screening";

        /// <summary>
        /// UI样式存储目录
        /// </summary>
        public static readonly string UIStylePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Temp", "UIStyle");

        /// <summary>
        /// 筛查模块：Dicom文件在本地存储的目录:Screening/DicomImage
        /// </summary>
        public static string ScreeningDicomLocalPath => AppHelper.GetFolderByParent(AppHelper.TempDirectory, BasePath_Screening, "DicomImage");

        /// <summary>
        /// 筛查模块：Dicom文件存储的目录:BasePath_Screening, "Dicom"
        /// </summary>
        public static string ScreeningImagePath => Path.Combine(BasePath_Screening, "Dicom");

        /// <summary>
        /// 筛查模块：截图本地保存目录：Screening/Screenshot
        /// </summary>
        public static string ScreeningScreenshotLocalPath => AppHelper.GetFolderByParent(AppHelper.TempDirectory, BasePath_Screening, "Screenshot");

        /// <summary>
        /// 筛查模块：截图保存目录： BasePath_Screening, "Screenshot"
        /// </summary>
        public static string ScreeningScreenshotPath => Path.Combine(BasePath_Screening, "Screenshot");

        /// <summary>
        /// 筛查模块：AIData本地保存目录： BasePath_Screening, "Screenshot"
        /// </summary>
        public static string ScreeningAIDataLocalPath => ScreeningDicomLocalPath;

        /// <summary>
        /// 筛查模块：AI标注的图片本地保存目录： Screening/Screenshot
        /// </summary>
        public static string ScreeningAIMarkTempPath => AppHelper.GetFolderByParent(AppHelper.TempDirectory, BasePath_Screening, "Temp");

        /// <summary>
        /// 获取指定目录下，指定匹配名称的文件，包括目录下的子目录中的文件
        /// </summary>
        /// <param name="directory"></param>
        /// <param name="searchPattern"></param>
        /// <returns></returns>
        public static List<string> GetFiles(string directory, string searchPattern)
        {
            List<string> fileFullPaths = new List<string>();
            var files = Directory.GetFiles(directory, searchPattern).ToList();
            fileFullPaths.AddRange(files);
            foreach (var subDir in Directory.GetDirectories(directory))
            {
                files = GetFiles(subDir, searchPattern);
                fileFullPaths.AddRange(files);
            }
            return fileFullPaths;
        }
    }
}
